package guiTesting;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.atlassian.crowd.model.group.Group;

import user.RetrieveGroupInfo;

public class SearchGroups extends JPanel {

	RetrieveGroupInfo searchGroup; 
	List<Group> grpSearchResults; 

	JPanel allComp; 

	JFrame appFrame; 
	JLabel sTerm;
	JButton sButton; 
	JTextField sTextField;
	JButton cancelButton;
	//Container allComp; 
	JPanel cPanel; 

	GridBagConstraints mainL ;

	final static boolean shouldFill = true;
	final static boolean shouldWeightX = true;
	final static boolean RIGHT_TO_LEFT = false;


	public SearchGroups(){
		createGUI();
		creatEvents();

	}

	public void createGUI() {

		
		allComp = new JPanel(); 
		//allComp.add(cPane);

		allComp.setLayout(new GridBagLayout());
		allComp.setBorder(BorderFactory.createTitledBorder("Search Groups"));
		componentsLayout();

		mainL = new GridBagConstraints();


		if (shouldFill) {
			//natural height, maximum width
			mainL.fill = GridBagConstraints.HORIZONTAL;
		}

		mainL.fill = GridBagConstraints.HORIZONTAL;
		mainL.weightx = 0.5;
		mainL.gridx = 0;
		mainL.gridy = 1;
		mainL.ipadx = 2;
		mainL.ipady = 2;
		mainL.anchor = GridBagConstraints.NORTH;
		allComp.add(cPanel, mainL);


	}



	public void componentsLayout(){
		GridBagConstraints sInputLayout = new GridBagConstraints();
		cPanel = new JPanel(new GridBagLayout());
		cPanel.setBorder(BorderFactory.createLineBorder(Color.YELLOW)); 

		if (shouldFill) {
			//natural height, maximum width
			sInputLayout.fill = GridBagConstraints.HORIZONTAL;
		}

		sTerm = new JLabel("Enter Search Term");
		sInputLayout.fill = GridBagConstraints.HORIZONTAL;
		sInputLayout.weightx = 0.5;
		sInputLayout.gridx = 1;
		sInputLayout.gridy = 0;
		sInputLayout.ipadx = 2;
		sInputLayout.ipady = 2;
		cPanel.add(sTerm, sInputLayout);

		sTextField = new JTextField(20);
		Dimension comDim = new Dimension (50, 30); 
		sTextField.setPreferredSize(comDim);
		sInputLayout.fill = GridBagConstraints.HORIZONTAL;
		sInputLayout.weightx = 0.5;
		sInputLayout.gridx = 2;
		sInputLayout.gridy = 0;
		sInputLayout.ipadx = 2;
		sInputLayout.ipady = 2;
		cPanel.add(sTextField, sInputLayout);


		sButton = new JButton("Search Groups");
		sButton.setPreferredSize(comDim);
		sInputLayout.fill = GridBagConstraints.HORIZONTAL;
		sInputLayout.weightx = 0.5;
		sInputLayout.gridx = 1;
		sInputLayout.gridy = 2;
		sInputLayout.ipadx = 2;
		sInputLayout.ipady = 2;
		cPanel.add(sButton, sInputLayout);

		cancelButton = new JButton("Cancel");
		cancelButton.setBorder(null);
		cancelButton.setPreferredSize(comDim);
		sInputLayout.fill = GridBagConstraints.HORIZONTAL;
		sInputLayout.weightx = 0.5;
		sInputLayout.gridx = 2;
		sInputLayout.gridy = 2;
		sInputLayout.ipadx = 2;
		sInputLayout.ipady = 2;
		cPanel.add(cancelButton, sInputLayout);

	}

	private void creatEvents() {


	}

	public JPanel getAllComp(){
		return allComp;
	}


}
